import { Dictionary } from '@/core/dict'
import { sortByField } from '@/common/util'
import { url, BaseRequest } from '@/core/request/base-request'

class DictApi extends BaseRequest {
  @url('/load-dict')
  async loadDict(key: string): Promise<Dictionary> {
    return Promise.resolve({
      sex: sortByField(
        [
          {
            code: 'male',
            label: '男性',
            order: 3,
          },
          {
            code: 'female',
            label: '女性',
            order: 2,
          },
        ],
        'order',
      ),
      multiContent: [
        {
          code: '001',
          order: 1,
          label: '内容1',
        },
        {
          code: '002',
          order: 2,
          label: '内容2',
        },
        {
          code: '003',
          order: 3,
          label: '内容3',
        },
      ],
    })
  }
}

const dictApi = new DictApi()

export default dictApi
